package com.aat.dxfy.ref;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.net.URL;

public class Demo01 {
	
	public static void main(String[] args) {
		try{
			URL url = new URL("https://www.baidu.com");
			String urlString = url.toExternalForm();
			System.out.println(urlString);
			
			
			Class<?> type = Class.forName("java.net.URL");

			Constructor<?> constructor = type.getConstructor(String.class);
			Object instance = constructor.newInstance("https://sitepoint.com/java");

			Method method = type.getMethod("toExternalForm");
			Object methodCallResult = method.invoke(instance);

			System.out.println(methodCallResult);
			
		}catch(Exception e){
			
		}

	}

}
